// EveryPosNumCheckView.cpp : implementation file
//

#include "stdafx.h"
#include "LotterSys.h"
#include "EveryPosNumCheckView.h"


// CEveryPosNumCheckView

IMPLEMENT_DYNCREATE(CEveryPosNumCheckView, CView)

CEveryPosNumCheckView::CEveryPosNumCheckView()
{

}

CEveryPosNumCheckView::~CEveryPosNumCheckView()
{
}

BEGIN_MESSAGE_MAP(CEveryPosNumCheckView, CView)
	ON_WM_CREATE()
	ON_WM_SIZE()
END_MESSAGE_MAP()


// CEveryPosNumCheckView drawing

void CEveryPosNumCheckView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}


// CEveryPosNumCheckView diagnostics

#ifdef _DEBUG
void CEveryPosNumCheckView::AssertValid() const
{
	CView::AssertValid();
}

#ifndef _WIN32_WCE
void CEveryPosNumCheckView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif
#endif //_DEBUG


int CEveryPosNumCheckView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here
	COLORREF clrMask = XTPImageManager()->SetMaskColor(RGB(0, 0, 0));
	XTPImageManager()->SetMaskColor(clrMask);

	m_wndProperty.Create(CRect(0, 0, 0, 0), this, 1000);
	m_wndProperty.SetOwner(GetTopLevelFrame());
	// Enable Office 2003 Theme
	m_wndProperty.SetTheme(xtpGridThemeOffice2007);

	return 0;
}

void CEveryPosNumCheckView::OnSize(UINT nType, int cx, int cy)
{
	CView::OnSize(nType, cx, cy);

	// TODO: Add your message handler code here
	if (m_wndProperty.GetSafeHwnd())
	{
		m_wndProperty.MoveWindow(0, 0, cx, cy - 0);
		m_wndProperty.Invalidate(FALSE);
	}
}

void CEveryPosNumCheckView::add_item( const char* item_name )
{
	CXTPPropertyGridItem* pCategory = m_wndProperty.AddCategory(item_name);
	pCategory->Expand() ;
	pCategory->SetExpandable(FALSE) ;
	

	CXTPPropertyGridItemBool* pItemBool = (CXTPPropertyGridItemBool*)pCategory->AddChildItem(
		new CXTPPropertyGridItemBool(_T("Select"), FALSE));
	pItemBool->SetID(500) ;
	pItemBool->SetCheckBoxStyle() ;

	for ( int i = 0 ; i < 10 ; i++ )
	{
		CString num ;num.Format("%d",i) ;
		CXTPPropertyGridItemBool* pItemBool = (CXTPPropertyGridItemBool*)pCategory->AddChildItem(
			new CXTPPropertyGridItemBool(num, FALSE));

		pItemBool->SetID(501+i);
		pItemBool->SetCheckBoxStyle();
	}
}

BOOL CEveryPosNumCheckView::get_checked( int id )
{
	CXTPPropertyGridItemBool* pItem = (CXTPPropertyGridItemBool*)m_wndProperty.FindItem(id) ;
	if (!pItem) return FALSE ;
	return pItem->GetBool() ;
}